package com.bytedance.article.common.c;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.support.v4.app.Fragment;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.permission.PermissionsResultAction;
import java.io.File;

final class d extends PermissionsResultAction {
    private final Activity a;
    private final String b;
    private final String c;
    private final Fragment d;
    private final int e;

    d(Activity arg1, String arg2, String arg3, Fragment arg4, int arg5) {
        this.a = arg1;
        this.b = arg2;
        this.c = arg3;
        this.d = arg4;
        this.e = arg5;

    }

    public final void onGranted() {
        int v4 = R.drawable.close_popup_textpage;
        if(!"mounted".equals(Environment.getExternalStorageState())) {
            UIUtils.showImageToast(this.a, v4, R.string.photo_error_no_sdcard);
            return;
        }

        Intent v0 = new Intent("android.media.action.IMAGE_CAPTURE");
        File v1 = new File(this.b);
        if(!v1.exists()) {
            v1.mkdirs();
        }

        v0.putExtra("output", Uri.fromFile(new File(v1, this.c)));
        try {
            if(this.d != null) {
                this.d.startActivityForResult(v0, this.e);
                return;
            }

            this.a.startActivityForResult(v0, this.e);
        }
        catch(Exception v0_1) {
            UIUtils.showImageToast(this.a, v4, R.string.photo_error_no_camera);
        }
    }

    public final void onDenied(String arg1) {
    }
}

